import 'dart:async';

import 'package:flutter/services.dart';

/// flutter call native
class FCN {
  static const MethodChannel _channel =
      const MethodChannel('elec_mobile_native_plugin_method_channel');

  /// Wifi 相关方法
  static Future<bool> wifi_enabled() async {final bool res = await _channel.invokeMethod('fcn_wifi_enabled');return res;}
  static Future<bool> wifi_ensure_open() async {final bool res = await _channel.invokeMethod('fcn_wifi_ensure_open');return res;}
  static Future<Map> wifi_query() async => _channel.invokeMethod('fcn_wifi_query');
  static Future<bool> wifi_connect(Map map) async => _channel.invokeMethod('fcn_wifi_connect', map);
  static Future<String> wifi_current() async => _channel.invokeMethod('fcn_wifi_current');
  static Future<int> wifi_strength() async {final int res = await _channel.invokeMethod('fcn_wifi_strength');return res;}

  /// 基础方法
  static Future<String> sysVer() async {final String res = await _channel.invokeMethod('fcn_sysVer');return res;}
  static Future<String> appVer() async {final String res = await _channel.invokeMethod('fcn_appVer');return res;}
  static Future<String> imei() async {final String res = await _channel.invokeMethod('fcn_imei');return res;}
  static Future<void> initBugly() async {await _channel.invokeMethod('fcn_initBugly');}
  static Future<void> checkUpgrade() async {await _channel.invokeMethod('fcn_checkUpgrade');}
  static Future<void> toast(String msg) async {await _channel.invokeMethod('fcn_toast',msg);}
  static Future<void> show_sysOption() async {await _channel.invokeMethod('fcn_show_sysOption');}
  static Future<void> show_sysTel(String number) async {await _channel.invokeMethod('fcn_show_sysTel',number);}
  static Future<int> get_file_length(String path) async {final int res = await _channel.invokeMethod('fcn_get_file_length',path);return res;}
  static Future<bool> req_write_permission() async { return await _channel.invokeMethod('req_write_permission'); }
  static Future<void> ios_request_location_auth() async {await _channel.invokeMethod('fcn_ios_request_location_auth');}

  /// 本地存储相关方法
  static Future<void> localStorage_insert_string(Map map) async {await _channel.invokeMethod('fcn_localStorage_insert_string',map);}
  static Future<void> localStorage_insert_int(Map map) async {await _channel.invokeMethod('fcn_localStorage_insert_int',map);}
  static Future<void> localStorage_delete(String key) async {await _channel.invokeMethod('fcn_localStorage_delete',key);}
  static Future<void> localStorage_update(Map map) async {await _channel.invokeMethod('fcn_localStorage_update',map);}
  static Future<String> localStorage_select_string(String key) async {final String res = await _channel.invokeMethod('fcn_localStorage_select_string',key);return res;}
  static Future<int> localStorage_select_int(String key) async {final int res = await _channel.invokeMethod('fcn_localStorage_select_int',key);return res;}


  /// 素材选择相关方法
  static Future<List<String>> selectPhoto() async {final List res = await _channel.invokeMethod('fcn_selectPhoto');return res?.map((e) => e as String)?.toList();}
  static Future<List<String>> selectVideo() async {final List res = await _channel.invokeMethod('fcn_selectVideo');return res?.map((e) => e as String)?.toList();}


  /// 计划表相关方法
  static Future<Map> fcn_schedule_create(Map map) async {final Map res = await _channel.invokeMethod('fcn_schedule_create',map);return res;}
  static Future<void> fcn_schedule_delete(Map map) async {await _channel.invokeMethod('fcn_schedule_delete',map);}
  static Future<void> fcn_schedule_update(Map map) async {await _channel.invokeMethod('fcn_schedule_update',map);}
  static Future<Map> fcn_schedule_select(Map map) async {final Map res = await _channel.invokeMethod('fcn_schedule_select',map);return res;}
  static Future<Map> fcn_schedule_select_page(Map map) async {final Map res = await _channel.invokeMethod('fcn_schedule_select_page',map);return res;}
  static Future<Map> fcn_schedule_check_expired(Map map) async {final Map res = await _channel.invokeMethod('fcn_schedule_check_expired',map);return res;}
  static Future<void> fcn_schedule_clear(Map map) async {await _channel.invokeMethod('fcn_schedule_clear',map);}


  /// 素材表相关方法
  static Future<Map> fcn_material_insert(Map map) async {final Map res = await _channel.invokeMethod('fcn_material_insert',map);return res;}
  static Future<void> fcn_material_delete(Map map) async {await _channel.invokeMethod('fcn_material_delete',map);}
  static Future<Map> fcn_material_update(Map map) async {final Map res = await _channel.invokeMethod('fcn_material_update',map);return res;}
  static Future<Map> fcn_material_select(Map map) async {final Map res = await _channel.invokeMethod('fcn_material_select',map);return res;}
  static Future<void> fcn_material_order(Map map) async {await _channel.invokeMethod('fcn_material_order',map);}

  /// 设备表相关方法
  static Future<bool> fcn_device_clear(Map map) async { return await _channel.invokeMethod('fcn_device_clear', map);}
  static Future<bool> fcn_device_delete(Map map) async { return await _channel.invokeMethod('fcn_device_delete', map); }
  static Future<Map> fcn_device_query(Map map) async {return await _channel.invokeMethod('fcn_device_query', map);}
  static Future<bool> fcn_device_store(Map map) async { return await _channel.invokeMethod('fcn_device_store', map); }

  /// 升级表相关方法
  static Future<bool> fcn_upgrade_clear(Map map) async { return await _channel.invokeMethod('fcn_upgrade_clear', map); }
  static Future<Map> fcn_upgrade_create(Map map) async { return await _channel.invokeMethod('fcn_upgrade_create', map); }
  static Future<bool> fcn_upgrade_delete(Map map) async { return await _channel.invokeMethod('fcn_upgrade_delete', map); }
  static Future<Map> fcn_upgrade_download(Map map) async { return await _channel.invokeMethod('fcn_upgrade_download', map); }
  static Future<Map> fcn_upgrade_update(Map map) async { return await _channel.invokeMethod('fcn_upgrade_update', map); }

  /// 设备表和升级表混合操作
  static Future<Map> fcn_device_upgrade_query(Map map) async { return await _channel.invokeMethod('fcn_device_upgrade_query', map); }

  /// 缓存文件相关操作方法
  static Future<String> fcn_get_cache_file() async { return await _channel.invokeMethod('fcn_get_cache_file'); }
  static Future<bool> fcn_delete_cache_file(String path) async { return await _channel.invokeMethod('fcn_delete_cache_file', path); }
}
